<template>
  <div class="clearfix">
    <el-form
        ref="TcForm"
        label-position="left"
        label-width="1rem"
        :model="Form"
    >
      <el-col class="ne-jminput-box" :span="item.span" v-if="item.show" v-for="(item,index) in Form" :key="index">
        <el-form-item v-if="item.type=='jmIpt'&&rules[index]" :prop="index + '.' + 'cValue'" :rules="rules[index]" :required="item.required" :label="item.cName" class="u-ipt">
          <el-input
              :disabled="item.disabled"
              clearable
              placeholder="请输入内容"
              v-model="item.cValue"
              class="input-with-select"
          >
            <el-select
                v-model="item.oValue"
                slot="append"
                placeholder="请选择"
                class="ne-select-box select-box"
            >
              <el-option
                  v-for="item2 in item.opt"
                  :key="item2.value"
                  :label="item2.label"
                  :value="item2.value"
              >
              </el-option>
            </el-select>
          </el-input>
        </el-form-item>
        <el-form-item v-if="item.type=='jmIpt'&&!rules[index]" :required="item.required" :label="item.cName" class="u-ipt">
          <el-input
              :disabled="item.disabled"
              clearable
              placeholder="请输入内容"
              v-model="item.cValue"
              class="input-with-select"
          >
            <el-select
                v-model="item.oValue"
                slot="append"
                placeholder="请选择"
                class="ne-select-box select-box"
            >
              <el-option
                  v-for="item2 in item.opt"
                  :key="item2.value"
                  :label="item2.label"
                  :value="item2.value"
              >
              </el-option>
            </el-select>
          </el-input>
        </el-form-item>
        <el-form-item v-if="item.type=='Ipt'&&rules[index]" :prop="index + '.' + 'cValue'" :rules="rules[index]" :required="item.required" :label="item.cName">
          <el-input
              :disabled="item.disabled"
              clearable
              placeholder="请输入内容"
              v-model="item.cValue"
              class="input-with-select"
          >
          </el-input>
        </el-form-item>
        <el-form-item v-if="item.type=='Ipt'&&!rules[index]" :required="item.required" :label="item.cName">
          <el-input
              :disabled="item.disabled"
              clearable
              placeholder="请输入内容"
              v-model="item.cValue"
              class="input-with-select"
          >
          </el-input>
        </el-form-item>
        <el-form-item v-if="item.type=='select'&&rules[index]" :prop="index + '.' + 'cValue'" :rules="rules[index]" :label="item.cName">
          <el-select  v-model="item.cValue"
                      :filterable="item.filterable"
                      :disabled="item.disabled"
                      placeholder="请选择" style="width: 100%">
            <el-option
                v-for="item2 in item.opt"
                :key="item2.value"
                :label="item2.label"
                :value="item2.value"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item v-if="item.type=='select'&&!rules[index]" :label="item.cName">
          <el-select  v-model="item.cValue"
                      :disabled="item.disabled"
                      :filterable="item.filterable"
                      placeholder="请选择" style="width: 100%">
            <el-option
                v-for="item2 in item.opt"
                :key="item2.value"
                :label="item2.label"
                :value="item2.value"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item v-if="item.type=='checkbox'&&rules[index]" :prop="index + '.' + 'cValue'" :rules="rules[index]" :required="item.required" :label="item.cName">
          <el-checkbox :disabled="item.disabled" v-model="item.cValue"></el-checkbox>
        </el-form-item>
        <el-form-item v-if="item.type=='checkbox'&&!rules[index]" :required="item.required" :label="item.cName">
          <el-checkbox :disabled="item.disabled" v-model="item.cValue"></el-checkbox>
        </el-form-item>
        <el-form-item v-if="item.type=='textarea'&&rules[index]" :prop="index + '.' + 'cValue'" :rules="rules[index]" :label="item.cName">
          <el-input :disabled="item.disabled" type="textarea" v-model="item.cValue"></el-input>
        </el-form-item>
        <el-form-item v-if="item.type=='textarea'&&!rules[index]" :label="item.cName">
          <el-input :disabled="item.disabled" type="textarea" v-model="item.cValue"></el-input>
        </el-form-item>
      </el-col>
      <el-col :span="24" class="text-center">
          <el-button type="primary" @click="submitFun">确定</el-button>
          <el-button @click="closeFun">取消</el-button>
      </el-col>
    </el-form>
  </div>
</template>

<script>
export default {
name: "TcForm",
  data(){
    return {
    }
  },
  props: {
    Form: {Object, Array},
    rules: {
      type: Object,
      default: () => {
        return {};
      }
    },
  },
  created() {
  },
  mounted() {

  },
  methods:{
    submitFun(){
      this.$emit('submitFun');
    },
    closeFun(){
      for(var key in this.Form){
        let item = this.Form[key];
        if(item.type=='checkbox'){
          item.cValue = true;
        }else{
          item.cValue = '';
        }
      }
      this.$emit('closeFun');
    }
  }
}
/**
 * type类型
 *         jmIpt精确模糊 input
 *         Ipt普通 input
 *
 */
</script>

<style lang="scss" scoped>
.ne-jminput-box{
  ::v-deep .el-button{
    padding: 0 0.15rem;
    border-radius: 0.05rem;
    height: 0.34rem;
    line-height: 0.32rem;
    min-height: 30px;
  }
    ::v-deep .el-form-item {
      padding: 0 .10rem;
    }
  ::v-deep .el-input__suffix{
    right: 0;
  }
  ::v-deep .el-select .el-input .el-select__caret{
    font-size: .12rem;
    position: relative;
    top: -.01rem;
  }
  //@media screen and (max-width:1300px){
  //  ::v-deep *{
  //    transform:scale(.995);
  //  }
  //}
  ::v-deep .select-box .el-input--suffix .el-input__inner{
    padding-left: .07rem;
    text-align: left;
    padding-right: 0.2rem;
    z-index: 9999;
  }
  .radio-mt {
    margin-top: .10rem;
  }
  .select-box {
    width: 1rem;
    padding: 0;
  }
  .ne-select-box{
    min-width: 44px;
    width: 0.56rem !important;
  }
  ::v-deep .el-input__icon{
    line-height: normal!important;
  }
  ::v-deep .el-form-item__content{
    line-height: .34rem!important;
  }
}

</style>
